package com.beerandjesus.sportofkings.handicapper.strategy.brisnet.singlefile;

import com.beerandjesus.sportofkings.handicapper.model.MaidenHorseAnalysisResultImpl;
import com.beerandjesus.sportofkings.handicapper.model.brisnet.singlefile.Horse;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class AuctionPriceStudFeeRatioResolver extends AbstractResolver {
    private static final BigDecimal FIVE = new BigDecimal(5);

    public AuctionPriceStudFeeRatioResolver() {
    }

    void resolveAuctionPriceStudFeeRatio(MaidenHorseAnalysisResultImpl result, Horse h) {
        // Look for 1st timers where auction price >= 4 times stud fee
        String auctionSire = "";
        if (h.getPastPerformances().size() == 0) {
            BigDecimal auctionPrice = new BigDecimal(getInteger(h.getAuctionPrice(), 1));
            BigDecimal studFee = new BigDecimal(getInteger(h.getCurrentStudFee(), 1));
            if (auctionPrice.compareTo(new BigDecimal(0)) != 0 &&
                    studFee.compareTo(new BigDecimal(0)) != 0) {
                BigDecimal res = auctionPrice.divide(studFee, RoundingMode.HALF_EVEN);
                if (res.compareTo(FIVE) >= 0) {
                    auctionSire = res.toString() + "x1";
                }
            }
        }
        result.setAuctionPriceStudFeeRatio(auctionSire);
    }


}